package demo3;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/redirectA")
public class RedirectServletA extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1. 模拟业务逻辑（生成订单ID）
        String orderId = "ORD" + System.currentTimeMillis();

        // 2. 重定向到redirectB（带参数）
        String projectPath = request.getContextPath(); // 获取项目根路径
        response.sendRedirect(projectPath + "/redirectB?orderId=" + orderId);
    }
}

